<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <textarea cols="50" rows="20" id="ta">

        </textarea>
        <div id="div1"></div>
        <script type="text/javascript">
            var ta = document.getElementById("ta");
            var div1 = document.getElementById("div1");
            //            ta.onkeyup = function(){
            //                div1.innerHTML = div1.innerHTML + "AAA";
            //                return false;
            //            }
            //            ta.onkeydown= function(){
            //                div1.innerHTML = div1.innerHTML + "BBB";
            //                return false;
            //            }
            //两个事件均被处理，先执行keydown,在执行keyup
            function f1(){
                if(event.type == "keydown") {
                    div1.innerHTML = div1.innerHTML + "AAA";
                    //return false;
                } else {
                    div1.innerHTML = div1.innerHTML + "BBB";
                }
            }
            ta.onkeyup = f1;
            ta.onkeydown= f1;
        </script>
    </body>
</html>
